<?php
/**
 * CEOfox
 *
 * @copyright  Copyright 2011-2012 CEOfox, Inc.
 * @license    http://ceofox.com/pages/license
 * @version    $Id: theme_template_body__start.php 57087 2013-05-24 09:40:17 $
 * @author     CEOfox, Inc.
 */
?>
<?php
  if(Phpfox::isModule('follow'))
  {
      Phpfox::isUser();
      echo '<script src="'.phpfox::getParam('core.path').'module/follow/static/jscript/follow.js"></script>';
      echo '<link rel="stylesheet" type="text/css" href="'.phpFox::getParam('core.path').'module/follow/static/css/default/default/follow.css'.'" />';
      
      $sModule = (defined('PHPFOX_IS_USER_PROFILE')) ? Phpfox::getLib('request')->get('req2') : Phpfox::getLib('request')->get('req1');
      $iItemId = (defined('PHPFOX_IS_USER_PROFILE')) ? Phpfox::getLib('request')->get('req3') : Phpfox::getLib('request')->getInt('req2');
      if(defined('PHPFOX_IS_PAGES_VIEW') && isset($this->_aVars['aPage']['page_id']))
      {
          $sModule = "pages";
          $iItemId = $this->_aVars['aPage']['page_id'];
      }
      $oFollow = Phpfox::getService('follow');
      if($sModule == 'pages')
      {
          if(Phpfox::getService('follow')->canFollow($iItemId, $sModule))
          {
            $bIsFollow = $oFollow->isFollow(Phpfox::getUserId(), $iItemId, $sModule);
            $bIsCurrentUser = false;
            echo '<script type="text/javascript">$Core.follow.url(\'' . Phpfox::getLib('url')->makeUrl('follow') . '\');</script>';
            echo '<script type="text/javascript">$Core.follow.setPhrases(\''. phpfox::getPhrase('follow.follow').'\', \''. phpfox::getPhrase('follow.unfollow').'\', \''. phpfox::getPhrase('follow.following').'\');</script>';
            echo '<script type="text/javascript">$Core.follow.getInfoFollow(
                \''.Phpfox::getUserId().'\',
                \''.(($bIsFollow == false)? 0: 1).'\',
                \''.(($bIsCurrentUser == false)? 0: 1).'\',
                \'pages\',
                \''.$iItemId.'\'
                );</script>';
          }
      }
      
      if(Phpfox::getParam('follow.refresh_notification') > 0)
      {
          $iNewestId = Phpfox::getService('follow.notifications')->getNewestId(Phpfox::getUserId());
          
          echo '<input type="hidden" id="follow_noti_newest_id" value="'.$iNewestId.'">';
          
          echo '<script type="text/javascript">
                $Behavior.followNotification = function()
                {
                    $Core.follow.reloadNotification('.Phpfox::getParam('follow.refresh_notification').')
                }
               </script>';
      }
  }
?>

